//
//  YZNetworkManager+simulate.m
//  YZMicroStock
//
//  Created by apple on 16/12/12.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZClient+simulate.h"

@implementation YZNetworkManager (simulate)

-(void)simU_getConfigureDataSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    [self.mainNetwork cq_noCacheGET:URL_FOR_FETCH_SIMU_CONFIGURE_DATA parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response,responseObject);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

- (void)simU_getBalanceDataSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    [self.mainNetwork cq_noCacheGET:URL_FOR_FETCH_SIMU_BALANCE_DATE parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response,responseObject);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

-(void)simU_getSaleListFirstDataSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    [self.mainNetwork cq_noCacheGET:URL_FOR_FITST_FETCH_DATALIST_ABOUT_SIMULATE parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response,responseObject);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

-(void)simU_submitTradeWithStockCode:(NSString *)stockCode andMoney:(NSString *)money andLever:(NSInteger)lever andQuitGain:(NSString *)quitGain andQuitLoss:(NSString *)quitLoss andPrincipal:(NSString *)principal andServiceCharge:(NSString *)serviceCharge andStockCount:(NSInteger)stockCount andToken:(NSString *)token success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *param = @{@"money":money,
                            @"lever":@(lever),
                            @"quitLoss":quitLoss,
                            @"quitGain":quitGain,
                            @"principal":principal,
                            @"serviceCharge":serviceCharge,
                            @"stockCode":stockCode,
                            @"volumeOrder":@(stockCount),
                            @"token":token,
                            COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    
    [self.mainNetwork cq_noCachePOST:URL_FOR_CREATE_STAEGRY_ABOUT_SIMULATE parameters:param success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


-(void)simU_getSaleListFromMemcaDataSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    [self.mainNetwork cq_noCacheGET:URL_FOR_MEMCA_FETCH_DATALIST_ABOUT_SIMULATE parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response,responseObject);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


-(void)simU_getSettleListDataSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    [self.mainNetwork cq_noCacheGET:URL_FOR_GET_SETTLE_LIST_ABOUT_SIMULATE parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response,responseObject);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


-(void)simU_fetchTradeSettlementDetailWithID:(long long)tid success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params = @{@"strategyId":@(tid),
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    [self.mainNetwork cq_noCacheGET:URL_FOR_GET_SETTLE_LIST_DETAIL_SIMULATE parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


-(void)simU_closeTradeWithID:(long long)tid andAlwaysCloseFlag:(BOOL)alwaysCloseFlag success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params = @{@"id":@(tid),
                             @"isAlwaysClose": alwaysCloseFlag?@"true":@"false",
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    [self.mainNetwork cq_noCachePOST:URL_FOR_SALE_STRATEGR_ABOUT_SIMULATE parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


-(void)simU_getBasicDataSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    [self.mainNetwork cq_noCacheGET:URL_FOR_FETCH_BASIC_DATA_ABOUT_SIMULATE parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response,responseObject);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


-(void)simU_EnterUsersuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *param = @{
                            COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    
    [self.mainNetwork cq_noCachePOST:URL_FOR_ENTER_SIMULATE parameters:param success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


-(void)simU_fetchStockAmonutStatisticsWithStockCode:(NSString *)stockCode success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    [self.mainNetwork cq_noCacheGET:URL_FOR_FETCH_SIMULATE_AMOUNT_STATISTICS parameters:@{@"stockCode":stockCode,COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


@end
